Skip to content

Conversation

iequidoo
Copy link
Collaborator

@iequidoo iequidoo commented Sep 7, 2025

Depends on #7116

fix: Make `calc_sort_timestamp()` a continuous function of message timestamp

This also simplifies the SQL query in `calc_sort_timestamp()` and prepares for creation of a db
index for it so that it's fast. Currently it doesn't uses indexes effectively; if a chat has many
messages, it's slow, i.e. O(n).

This as well fixes ordering of delayed encrypted outgoing messages; before, they could be sorted
above "Messages are end-to-end encrypted."

feat: Add timestamp to msgs_index7 to employ it in calc_sort_timestamp()

Tested on some random chat, the SQL query took 1.411202ms (vs 6.692714ms before) in median. Still
looks a bit slow, but already better.

@iequidoo iequidoo marked this pull request as draft September 7, 2025 11:23
@iequidoo iequidoo force-pushed the iequidoo/unbend-calc_sort_timestamp branch 2 times, most recently from a7ef844 to fe2e94c Compare September 8, 2025 05:47
@iequidoo iequidoo changed the base branch from iequidoo/test_sync_sentbox_then_inbox to main September 8, 2025 05:48
@iequidoo iequidoo force-pushed the iequidoo/unbend-calc_sort_timestamp branch 3 times, most recently from 295215c to f05e585 Compare September 10, 2025 10:46
@iequidoo iequidoo changed the title fix: Make calc_sort_timestamp() a continuous function of message timestamp fix: Make calc_sort_timestamp() a continuous function of message timestamp and improve its performance Sep 10, 2025
@iequidoo iequidoo changed the base branch from main to link2xt/ykltkokxntvk September 10, 2025 10:48
@iequidoo iequidoo force-pushed the iequidoo/unbend-calc_sort_timestamp branch from f05e585 to 462985d Compare September 10, 2025 10:50
@iequidoo iequidoo marked this pull request as ready for review September 10, 2025 10:57
@iequidoo iequidoo requested review from link2xt and r10s September 10, 2025 10:58
Msg#13: info (Contact#Contact#Info): alice@example.org invited you to join this group.

Waiting for the device of alice@example.org to reply… [NOTICED][INFO]
Msg#15: info (Contact#Contact#Info): alice@example.org replied, waiting for being added to the group… [NOTICED][INFO]
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This reply is already encrypted, so now the message order looks more correct as to me. If an old delayed message arrives, even if it's outgoing, e.g. from another device, it also will be sorted correctly

…mestamp

This also simplifies the SQL query in `calc_sort_timestamp()` and prepares for creation of a db
index for it so that it's fast. Currently it doesn't uses indexes effectively; if a chat has many
messages, it's slow, i.e. O(n).

This as well fixes ordering of delayed encrypted outgoing messages; before, they could be sorted
above "Messages are end-to-end encrypted."
Tested on some random chat, the SQL query took 1.411202ms (vs 6.692714ms before) in median. Still
looks a bit slow, but already better.
@link2xt link2xt force-pushed the link2xt/ykltkokxntvk branch from 0f94529 to 5051240 Compare September 13, 2025 00:16
@link2xt link2xt force-pushed the iequidoo/unbend-calc_sort_timestamp branch from 7c44f7d to dce6e5d Compare September 13, 2025 00:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant